//
//  BQAccountManager.m
//  BeeQuick
//
//  Created by Vivitickey on 2017/4/27.
//  Copyright © 2017年 test. All rights reserved.
//

#import "BQAccountManager.h"

@implementation BQAccountManager

+ (BQAccountManager *)sharedInstance {
    static dispatch_once_t onceToken;
    static BQAccountManager *__instance__;
    
    dispatch_once(&onceToken, ^{
        __instance__ = [BQAccountManager new];
        
        __instance__.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", @"text/html", nil];
        
        //  请求格式（默认：二进制）
        __instance__.requestSerializer = [AFJSONRequestSerializer serializer];
    });
    return __instance__;
}

#pragma mark
#pragma mark - post方法
- (void)POSTWithUrlString:(NSString *)urlString parameters:(id)parameters success:(void(^)(id responseObject))successBlock failure:(void(^)(NSError *error))failureBlock{
    
    [self POST:urlString parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        // 把AFN获取的responseObject,回调给外界
        if (successBlock) {
            successBlock(responseObject);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (failureBlock) {
            failureBlock(error);
        }
    }];
    
}

@end
